from rich import print
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from rich.table import Table
from rich.layout import Layout
from rich.align import Align


from .menu import menu


import os

def clear():
    os.system('cls')
    os.system('clear')
class mainUI:
    def __init__(self):
            clear()
            console = Console()
#             print('''
#               _____                  _______                  _____                    _____                    _____                   _____          
#          /\    \                /::\    \                /\    \                  /\    \                  /\    \                 /\    \         
#         /::\____\              /::::\    \              /::\____\                /::\    \                /::\    \               /::\____\        
#        /:::/    /             /::::::\    \            /::::|   |               /::::\    \              /::::\    \             /::::|   |        
#       /:::/    /             /::::::::\    \          /:::::|   |              /::::::\    \            /::::::\    \           /:::::|   |        
#      /:::/    /             /:::/~~\:::\    \        /::::::|   |             /:::/\:::\    \          /:::/\:::\    \         /::::::|   |        
#     /:::/____/             /:::/    \:::\    \      /:::/|::|   |            /:::/__\:::\    \        /:::/__\:::\    \       /:::/|::|   |        
#    /::::\    \            /:::/    / \:::\    \    /:::/ |::|   |           /::::\   \:::\    \      /::::\   \:::\    \     /:::/ |::|   |        
#   /::::::\____\________  /:::/____/   \:::\____\  /:::/  |::|___|______    /::::::\   \:::\    \    /::::::\   \:::\    \   /:::/  |::|   | _____  
#  /:::/\:::::::::::\    \|:::|    |     |:::|    |/:::/   |::::::::\    \  /:::/\:::\   \:::\    \  /:::/\:::\   \:::\____\ /:::/   |::|   |/\    \ 
# /:::/  |:::::::::::\____\:::|____|     |:::|    /:::/    |:::::::::\____\/:::/  \:::\   \:::\____\/:::/  \:::\   \:::|    /:: /    |::|   /::\____\
# \::/   |::|~~~|~~~~~     \:::\    \   /:::/    /\::/    / ~~~~~/:::/    /\::/    \:::\  /:::/    /\::/   |::::\  /:::|____\::/    /|::|  /:::/    /
#  \/____|::|   |           \:::\    \ /:::/    /  \/____/      /:::/    /  \/____/ \:::\/:::/    /  \/____|:::::\/:::/    / \/____/ |::| /:::/    / 
#        |::|   |            \:::\    /:::/    /               /:::/    /            \::::::/    /         |:::::::::/    /          |::|/:::/    /  
#        |::|   |             \:::\__/:::/    /               /:::/    /              \::::/    /          |::|\::::/    /           |::::::/    /   
#        |::|   |              \::::::::/    /               /:::/    /               /:::/    /           |::| \::/____/            |:::::/    /    
#        |::|   |               \::::::/    /               /:::/    /               /:::/    /            |::|  ~|                  |::::/    /     
#        |::|   |                \::::/    /               /:::/    /               /:::/    /             |::|   |                  /:::/    /      
#        \::|   |                 \::/____/               /:::/    /               /:::/    /              \::|   |                 /:::/    /       
#         \:|   |                  ~~                     \::/    /                \::/    /                \:|   |                 \::/    /        
#          \|___|                                          \/____/                  \/____/                  \|___|                  \/____/         
                                                                                                                                                  
#     ''')
        

            table = Table(show_header=False, 
            header_style="bold magenta",expand=True,caption_justify="center")
            table.add_row(
                "1.【data】数据管理", "2.【backups】已备份的数据", "3.【cloud】云数据下载", "4.【history】历史记录"
            )
            panel = Panel(Text("欢迎使用数据集管理器，输入需要使用的功能并回车开始使用", justify="center"))
            welcome_text = Text("欢迎使用数据集管理，输入需要使用的功能命令并回车开始使用,\n Welcome to use the KOMARN dataset management. Enter the required features and press enter to start using them", justify="center", style="bold white")
            welcome_panel = Panel(
                welcome_text, 
                title="欢迎", 
                border_style="bold #00008B",  # 深蓝色边框
                style="on #00008B",           
                padding=(8, 0)  # 设置垂直方向上的填充以增加高度
            )
            console.print(welcome_panel)

            print(panel)
            console.print(table)

            console.print("[bold magenta]$请输入需要使用的功能：[/bold magenta]",end="")
            useFunction = input()

            menuEntity = menu()
            menuEntity.welcome(useFunction)